<!-- build time:Tue Dec 17 2019 19:26:40 GMT+0800 (GMT+08:00) --><!doctype html><html class="theme-next mist" lang="zh-Hans"><head><meta name="generator" content="Hexo 3.8.0"><meta name="google-site-verification" content="7Tau9WyVgxnsEY9oYedu9g0U6_8akOX3wiKbaYcrg9A"><meta name="baidu-site-verification" content="EVwLiaxdxX"><link href="/css/xps13.css" rel="stylesheet" type="text/css"><link href="/css/message.css" rel="stylesheet" type="text/css"><script type="text/javascript" src="/js/jquery-1.11.3.min.js"></script><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1"><meta http-equiv="Cache-Control" content="no-transform"><meta http-equiv="Cache-Control" content="no-siteapp"><link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css"><link href="/css/main.css?v=5.1.1" rel="stylesheet" type="text/css"><meta name="keywords" content="GitLab,CI/CD,DevOps,Harbor,Kubernetes,Jenkins,"><link rel="alternate" href="/atom.xml" title="MrBird" type="application/atom+xml"><link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.1"><meta name="description" content="CICD（Continuous Integration/Continuous Deployment），持续集成持续部署的意思。完成CICD实践需要Kubernetes集群，Harbor，GitLab和Jenkins等软件配合完成，在前面几篇博客中，我已经搭建好了Kubernetes集群，并且在master节点（192.168.33.11,CentOS）上安装好了Harbor、GitLab和Jenk"><meta name="keywords" content="GitLab,CI&#x2F;CD,DevOps,Harbor,Kubernetes,Jenkins"><meta property="og:type" content="article"><meta property="og:title" content="CI&#x2F;CD实践笔记"><meta property="og:url" content="http://mrbird.cc/CI-CD-Practice-Note.html"><meta property="og:site_name" content="MrBird"><meta property="og:description" content="CICD（Continuous Integration/Continuous Deployment），持续集成持续部署的意思。完成CICD实践需要Kubernetes集群，Harbor，GitLab和Jenkins等软件配合完成，在前面几篇博客中，我已经搭建好了Kubernetes集群，并且在master节点（192.168.33.11,CentOS）上安装好了Harbor、GitLab和Jenk"><meta property="og:locale" content="zh-Hans"><meta property="og:image" content="http://mrbird.cc/img/QQ截图20191118145712.png"><meta property="og:image" content="http://mrbird.cc/img/QQ截图20191118151519.png"><meta property="og:image" content="http://mrbird.cc/img/QQ截图20191118153441.png"><meta property="og:image" content="http://mrbird.cc/img/QQ截图20191118153948.png"><meta property="og:image" content="http://mrbird.cc/img/QQ截图20191120162821.png"><meta property="og:image" content="http://mrbird.cc/img/QQ截图20191118164351.png"><meta property="og:image" content="http://mrbird.cc/img/QQ截图20191120162943.png"><meta property="og:image" content="http://mrbird.cc/img/QQ截图20191119184432.png"><meta property="og:image" content="http://mrbird.cc/img/QQ截图20191119184535.png"><meta property="og:image" content="http://mrbird.cc/img/QQ截图20191119184638.png"><meta property="og:image" content="http://mrbird.cc/img/QQ截图20191119191043.png"><meta property="og:image" content="http://mrbird.cc/img/QQ截图20191119192134.png"><meta property="og:image" content="http://mrbird.cc/img/QQ截图20191120091638.png"><meta property="og:image" content="http://mrbird.cc/img/QQ截图20191120091910.png"><meta property="og:image" content="http://mrbird.cc/img/QQ截图20191120092313.png"><meta property="og:image" content="http://mrbird.cc/img/QQ截图20191120092425.png"><meta property="og:image" content="http://mrbird.cc/img/QQ截图20191120093459.png"><meta property="og:image" content="http://mrbird.cc/img/QQ截图20191120094028.png"><meta property="og:image" content="http://mrbird.cc/img/QQ截图20191120094121.png"><meta property="og:image" content="http://mrbird.cc/img/QQ截图20191120141218.png"><meta property="og:image" content="http://mrbird.cc/img/QQ截图20191120141809.png"><meta property="og:image" content="http://mrbird.cc/img/QQ截图20191120141908.png"><meta property="og:image" content="http://mrbird.cc/img/20191120142110.png"><meta property="og:image" content="http://mrbird.cc/img/QQ截图20191121170401.png"><meta property="og:image" content="http://mrbird.cc/img/QQ截图20191121170425.png"><meta property="og:image" content="http://mrbird.cc/img/QQ截图20191121170512.png"><meta property="og:image" content="http://mrbird.cc/img/20191121184651.png"><meta property="og:image" content="http://mrbird.cc/img/QQ截图20191121184855.png"><meta property="og:image" content="http://mrbird.cc/img/QQ截图20191121184943.png"><meta property="og:image" content="http://mrbird.cc/img/QQ截图20191121192052.png"><meta property="og:image" content="http://mrbird.cc/img/QQ截图20191121190234.png"><meta property="og:image" content="http://mrbird.cc/img/QQ截图20191121190318.png"><meta property="og:image" content="http://mrbird.cc/img/QQ截图20191121191654.png"><meta property="og:updated_time" content="2019-11-23T06:13:43.424Z"><meta name="twitter:card" content="summary"><meta name="twitter:title" content="CI&#x2F;CD实践笔记"><meta name="twitter:description" content="CICD（Continuous Integration/Continuous Deployment），持续集成持续部署的意思。完成CICD实践需要Kubernetes集群，Harbor，GitLab和Jenkins等软件配合完成，在前面几篇博客中，我已经搭建好了Kubernetes集群，并且在master节点（192.168.33.11,CentOS）上安装好了Harbor、GitLab和Jenk"><meta name="twitter:image" content="http://mrbird.cc/img/QQ截图20191118145712.png"><script type="text/javascript" id="hexo.configurations">var NexT=window.NexT||{},CONFIG={root:"/",scheme:"Mist",sidebar:{position:"left",display:"always",offset:12,offset_float:0,b2t:!1,scrollpercent:!1},fancybox:!1,motion:!1}</script><title>CI/CD实践笔记 | MrBird</title></head><body ondragstart="return!1" class="animsition" lang="zh-Hans" style="overflow-x:hidden;padding-right:280px"><script type="text/javascript" src="/js/mo.min.js"></script><style>@media (min-width:768px) and (max-width:991px){body .header-innerr{width:700px!important}}.header-innerr{margin:0 auto;padding:100px 0 70px;width:880px}@media (min-width:1600px){.container .header-innerr{width:1200px}}.header-innerr{position:relative}.header-innerr{padding:20px 0 0}.header-innerr:after,.header-innerr:before{content:" ";display:table}.header-innerr:after{clear:both}@media (max-width:767px){.header-innerr{width:auto;padding:10px;margin-bottom:-20px}}</style><div class="container sidebar-position-left page-post-detail"><div class="headband"></div><header id="header" class="header"><div class="header-inner"><div class="site-brand-wrapper"><div class="site-meta"><link href="https://fonts.font.im/css?family=Merienda" rel="stylesheet"><div class="custom-logo-site-title"><a href="/" class="brand" rel="start"><span class="logo-line-before"><i></i></span> <span class="site-title" style="font-family:Merienda;font-size:1.3rem">MrBird</span> <span class="logo-line-after"><i></i></span></a></div><p class="site-subtitle"></p></div><div class="site-nav-toggle"><button><span class="btn-bar"></span> <span class="btn-bar"></span> <span class="btn-bar"></span></button></div></div><nav class="site-nav"><ul id="menu" class="menu"><li class="menu-item menu-item-home"><a href="/" rel="section">HOME</a></li><li class="menu-item menu-item-archives"><a href="/archives/" rel="section">ARCHIVES</a></li><li class="menu-item menu-item-tags"><a href="/tags/" rel="section">TAGS</a></li><li class="menu-item menu-item-friends"><a href="/friends/" rel="section">FRIENDS</a></li><div class="sidebar-toggle" style="display:none"><div class="sidebar-toggle-line-wrap"><span class="sidebar-toggle-line sidebar-toggle-line-first"></span> <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span> <span class="sidebar-toggle-line sidebar-toggle-line-last"></span></div></div></ul><div class="site-search"><div class="popup search-popup local-search-popup"><div class="local-search-header clearfix"><span class="search-icon"><i class="fa fa-search"></i> </span><span class="popup-btn-close"><i class="fa fa-times-circle"></i></span><div class="local-search-input-wrapper"><input autocomplete="off" placeholder="Search" spellcheck="false" type="text" id="local-search-input"></div></div><div id="local-search-result"></div></div></div></nav></div><div class="header-innerr"><div class="note info" style="margin:0;letter-spacing:.15px">🐤手把手教你搭建<strong>Spring Cloud微服务权限系统</strong>（从零到部署）：<a style="color:#40dab2;font-weight:600" href="https://www.kancloud.cn/mrbird/spring-cloud" target="_blank">https://www.kancloud.cn/mrbird/spring-cloud</a></div></div></header><main id="main" class="main"><div class="main-inner"><div class="content-wrap"><div id="content" class="content"><div id="posts" class="posts-expand"><article class="post post-type-normal" itemscope itemtype="http://schema.org/Article"><link itemprop="mainEntityOfPage" href="http://mrbird.cc/CI-CD-Practice-Note.html"><span hidden itemprop="author" itemscope itemtype="http://schema.org/Person"><meta itemprop="name" content="MrBird"><meta itemprop="description" content=""><meta itemprop="image" content="/images/blogImage.jpg"></span><span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization"><meta itemprop="name" content="MrBird"></span><header class="post-header"><h1 class="post-title" itemprop="name headline">CI/CD实践笔记</h1><div class="post-meta"><span class="post-time"><span class="post-meta-item-icon"><i class="fa fa-calendar-o"></i> </span><span class="post-meta-item-text">Posted on</span> <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-11-18T13:52:58+08:00">2019-11-18 </time></span><span></span> <span class="post-meta-divider">|</span> <span class="page-pv"><i class="fa fa-laptop"></i>&nbsp;&nbsp;Visit count <span class="busuanzi-value" id="busuanzi_value_page_pv"></span></span></div></header><div class="post-body" itemprop="articleBody"><p>CICD（<strong>C</strong>ontinuous <strong>I</strong>ntegration/<strong>C</strong>ontinuous <strong>D</strong>eployment），持续集成持续部署的意思。完成CICD实践需要Kubernetes集群，Harbor，GitLab和Jenkins等软件配合完成，在前面几篇博客中，我已经搭建好了Kubernetes集群，并且在master节点（192.168.33.11,CentOS）上安装好了Harbor、GitLab和Jenkins，有需要可以参考下。<a id="more"></a></p><h2 id="实践准备"><a href="#实践准备" class="headerlink" title="实践准备"></a>实践准备</h2><h3 id="CICD流程图"><a href="#CICD流程图" class="headerlink" title="CICD流程图"></a>CICD流程图</h3><p>CICD的大致流程如下图所示：</p><p><img src="img/QQ截图20191118145712.png" alt="QQ截图20191118145712.png"></p><ol><li><p>开发者将最新代码提交到GitLab仓库；</p></li><li><p>GitLab WebHook触发Jenkins构建流水线：</p><p>2.1 拉取最新代码；</p><p>2.2 Maven打包，打包过程中会先进行单元测试；</p><p>2.3 单元测试通过，构建Docker镜像；</p><p>2.4 将最新镜像推送到Harbor；</p><p>2.5 更新Kubernetes相关配置镜像版本。</p></li><li><p>Kubernetes感知到镜像更新，从Harbor拉取最新镜像，滚动升级；</p></li><li><p>开发者看到最新的代码效果。</p></li></ol><h3 id="项目准备"><a href="#项目准备" class="headerlink" title="项目准备"></a>项目准备</h3><p>这里我们在Windows上使用IDEA、Spring Boot构建一个简单的Java Web项目，项目名为demo，项目pom如下所示：</p><figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;?xml version="1.0" encoding="UTF-8"?&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">project</span> <span class="attr">xmlns</span>=<span class="string">"http://maven.apache.org/POM/4.0.0"</span> <span class="attr">xmlns:xsi</span>=<span class="string">"http://www.w3.org/2001/XMLSchema-instance"</span></span></span><br><span class="line"><span class="tag">         <span class="attr">xsi:schemaLocation</span>=<span class="string">"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">modelVersion</span>&gt;</span>4.0.0<span class="tag">&lt;/<span class="name">modelVersion</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">parent</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.springframework.boot<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>spring-boot-starter-parent<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">version</span>&gt;</span>2.2.1.RELEASE<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">relativePath</span>/&gt;</span> <span class="comment">&lt;!-- lookup parent from repository --&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">parent</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>cc.mrbird<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>demo<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">version</span>&gt;</span>0.0.1-SNAPSHOT<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">name</span>&gt;</span>demo<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">description</span>&gt;</span>Demo project for Spring Boot<span class="tag">&lt;/<span class="name">description</span>&gt;</span></span><br><span class="line"></span><br><span class="line">    <span class="tag">&lt;<span class="name">properties</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">java.version</span>&gt;</span>1.8<span class="tag">&lt;/<span class="name">java.version</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">properties</span>&gt;</span></span><br><span class="line"></span><br><span class="line">    <span class="tag">&lt;<span class="name">dependencies</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.springframework.boot<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>spring-boot-starter-web<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line"></span><br><span class="line">        <span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.springframework.boot<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>spring-boot-starter-test<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">scope</span>&gt;</span>test<span class="tag">&lt;/<span class="name">scope</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">dependencies</span>&gt;</span></span><br><span class="line"></span><br><span class="line">    <span class="tag">&lt;<span class="name">build</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">plugins</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">plugin</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.springframework.boot<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>spring-boot-maven-plugin<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;/<span class="name">plugin</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">plugins</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">build</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;/<span class="name">project</span>&gt;</span></span><br></pre></td></tr></table></figure><p></p><p>在Boot入口类中添加一个简单的Controller方法：</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@RestController</span></span><br><span class="line"><span class="meta">@SpringBootApplication</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">DemoApplication</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">        SpringApplication.run(DemoApplication.class, args);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="meta">@GetMapping</span>(<span class="string">"hello"</span>)</span><br><span class="line">    <span class="function"><span class="keyword">public</span> String <span class="title">index</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="string">"hello world"</span>;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure><p></p><p>上面方法提供了一个<code>/hello</code>接口，简单返回<code>hello world</code>信息。</p><p>接着编写一个简单的单元测试：</p><p><img src="img/QQ截图20191118151519.png" alt="QQ截图20191118151519.png"></p><p>代码如下：</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@RunWith</span>(SpringRunner.class)</span><br><span class="line"><span class="meta">@SpringBootTest</span></span><br><span class="line"><span class="meta">@AutoConfigureMockMvc</span></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">DemoApplicationTests</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="meta">@Autowired</span></span><br><span class="line">    <span class="keyword">private</span> MockMvc mockMvc;</span><br><span class="line"></span><br><span class="line">    <span class="meta">@Test</span></span><br><span class="line">    <span class="function"><span class="keyword">void</span> <span class="title">testIndex</span><span class="params">()</span> <span class="keyword">throws</span> Exception </span>&#123;</span><br><span class="line">        mockMvc.perform(MockMvcRequestBuilders.get(<span class="string">"/hello"</span>))</span><br><span class="line">                .andExpect(MockMvcResultMatchers.content().string(<span class="string">"hello world"</span>));</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure><p></p><p>最后在项目的根目录下新建一个Dockerfile：</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">FROM openjdk:8u212-jre</span><br><span class="line">MAINTAINER MrBird 852252810@qq.com</span><br><span class="line"></span><br><span class="line">COPY target/demo-0.0.1-SNAPSHOT.jar /demo-0.0.1-SNAPSHOT.jar</span><br><span class="line">ENTRYPOINT [&quot;java&quot;, &quot;-jar&quot;, &quot;/demo-0.0.1-SNAPSHOT.jar&quot;]</span><br></pre></td></tr></table></figure><p></p><p>至此简单的Java Web项目就准备好了。</p><h3 id="GitLab准备"><a href="#GitLab准备" class="headerlink" title="GitLab准备"></a>GitLab准备</h3><p>注册一个新的GitLab账号，比如mrbird，然后在GitLab新建一个项目，名称为Demo：</p><p><img src="img/QQ截图20191118153441.png" alt="QQ截图20191118153441.png"></p><p>因为我们后续需要在Windows下将项目提交到GitLab，并在192.168.33.11上拉取该项目，所以我们需要在Windows和192.168.33.11服务器上生成SSH Key，并添加到GitLab中。</p><p>在Windows及192.168.33.11虚拟机通过下面的命令生成SSH Key：</p><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">ssh-keygen -t rsa -C <span class="string">"852252810@qq.com"</span></span><br><span class="line"></span><br><span class="line">cat ~/.ssh/id_rsa.pub</span><br></pre></td></tr></table></figure><p></p><p>将SSH Key添加到GitLab：</p><p><img src="img/QQ截图20191118153948.png" alt="QQ截图20191118153948.png"></p><p>这样我们后续的push和pull操作就不需要输入用户名了。</p><p>接着我们将上面创建的Demo项目推送到GitLab中（在IDEA的Terminal窗口中操作，个人习惯用命令行）：</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"># 配置Git</span><br><span class="line">git config --global user.name &quot;mrbird&quot;</span><br><span class="line">git config --global user.email &quot;852252810@qq.com&quot;</span><br><span class="line"></span><br><span class="line"># 初始化Git仓库</span><br><span class="line">git init</span><br><span class="line"></span><br><span class="line"># commit</span><br><span class="line">git commit -am init</span><br><span class="line"></span><br><span class="line"># 添加远程仓库</span><br><span class="line">git remote add origin ssh://git@gitlab.mrbird.cc:2223/mrbird/demo.git</span><br><span class="line"></span><br><span class="line"># 推送到远程仓库</span><br><span class="line">git push origin master</span><br></pre></td></tr></table></figure><p></p><p>推送成功后，回到GitLab页面可以看到项目已经推送OK了：</p><p><img src="img/QQ截图20191120162821.png" alt="QQ截图20191118154957.png"></p><h3 id="Kubernetes部署SpringBoot项目"><a href="#Kubernetes部署SpringBoot项目" class="headerlink" title="Kubernetes部署SpringBoot项目"></a>Kubernetes部署SpringBoot项目</h3><p>在192.168.33.11服务器上将刚刚的项目从GitLab中克隆下来:</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git clone ssh://git@gitlab.mrbird.cc:2223/mrbird/demo.git</span><br></pre></td></tr></table></figure><p>因为打包需要Maven环境，所以接着配置Maven：</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"># 下载Maven安装包</span><br><span class="line">wget http://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.2/binaries/apache-maven-3.6.2-bin.tar.gz</span><br><span class="line"></span><br><span class="line"># 解压</span><br><span class="line">tar -xzvf apache-maven-3.6.2-bin.tar.gz</span><br><span class="line"></span><br><span class="line"># 修改环境变量</span><br><span class="line">vim /etc/profile</span><br></pre></td></tr></table></figure><p></p><p>添加如下内容：</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">M2_HOME=/home/vagrant/apache-maven-3.6.2</span><br><span class="line">export PATH=$PATH:$JAVA_HOME/bin:$M2_HOME/bin</span><br></pre></td></tr></table></figure><p></p><p>让修改生效：</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">source /etc/profile</span><br></pre></td></tr></table></figure><p></p><p>验证下是否安装成功：</p><p><img src="img/QQ截图20191118164351.png" alt="QQ截图20191118164351.png"></p><p>环境准备好后，将目录切换到刚刚<code>git clone</code>的demo目录下，执行<code>mvn clean package</code>命令，完成后可以看到fat jar：</p><p><img src="img/QQ截图20191120162943.png" alt="QQ截图20191118171428.png"></p><p>接着执行<code>docker build -t docker.mrbird.cc/febs/demo .</code>命令构建docker镜像：</p><p><img src="img/QQ截图20191119184432.png" alt="QQ截图20191119184432.png"></p><p>构建成功后执行<code>docker push docker.mrbird.cc/febs/demo</code>命令推送到Harbor：</p><p><img src="img/QQ截图20191119184535.png" alt="QQ截图20191119184535.png"></p><p>访问Harbor管理页面，可以看到镜像已经推送上来了：</p><p><img src="img/QQ截图20191119184638.png" alt="QQ截图20191119184638.png"></p><p>接着编写个简单的Kubernetes配置文件（demo.yml）：</p><figure class="highlight yml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">apiVersion:</span> <span class="string">v1</span></span><br><span class="line"><span class="attr">kind:</span> <span class="string">Service</span></span><br><span class="line"><span class="attr">metadata:</span></span><br><span class="line"><span class="attr">  name:</span> <span class="string">demo-service</span></span><br><span class="line"><span class="attr">spec:</span></span><br><span class="line"><span class="attr">  type:</span> <span class="string">NodePort</span></span><br><span class="line"><span class="attr">  ports:</span></span><br><span class="line"><span class="attr">    - port:</span> <span class="number">8080</span></span><br><span class="line"><span class="attr">      targetPort:</span> <span class="number">8080</span></span><br><span class="line"><span class="attr">      nodePort:</span> <span class="number">30000</span></span><br><span class="line"><span class="attr">  selector:</span></span><br><span class="line"><span class="attr">    name:</span> <span class="string">demo-app</span></span><br><span class="line"><span class="meta">---</span></span><br><span class="line"><span class="attr">apiVersion:</span> <span class="string">apps/v1</span></span><br><span class="line"><span class="attr">kind:</span> <span class="string">Deployment</span></span><br><span class="line"><span class="attr">metadata:</span></span><br><span class="line"><span class="attr">  name:</span> <span class="string">demo-deployment</span></span><br><span class="line"><span class="attr">spec:</span></span><br><span class="line"><span class="attr">  selector:</span></span><br><span class="line"><span class="attr">    matchLabels:</span></span><br><span class="line"><span class="attr">      name:</span> <span class="string">demo-app</span></span><br><span class="line"><span class="attr">  replicas:</span> <span class="number">2</span></span><br><span class="line"><span class="attr">  template:</span></span><br><span class="line"><span class="attr">    metadata:</span></span><br><span class="line"><span class="attr">      labels:</span></span><br><span class="line"><span class="attr">        name:</span> <span class="string">demo-app</span></span><br><span class="line"><span class="attr">    spec:</span></span><br><span class="line"><span class="attr">      containers:</span></span><br><span class="line"><span class="attr">        - name:</span> <span class="string">demo</span></span><br><span class="line"><span class="attr">          image:</span> <span class="string">docker.mrbird.cc/febs/demo</span></span><br><span class="line"><span class="attr">          ports:</span></span><br><span class="line"><span class="attr">            - containerPort:</span> <span class="number">8080</span></span><br><span class="line"><span class="attr">          resources:</span></span><br><span class="line"><span class="attr">            limits:</span></span><br><span class="line"><span class="attr">              cpu:</span> <span class="number">500</span><span class="string">m</span></span><br><span class="line"><span class="attr">              memory:</span> <span class="number">500</span><span class="string">Mi</span></span><br><span class="line"><span class="attr">            requests:</span></span><br><span class="line"><span class="attr">              cpu:</span> <span class="number">200</span><span class="string">m</span></span><br><span class="line"><span class="attr">              memory:</span> <span class="number">200</span><span class="string">Mi</span></span><br></pre></td></tr></table></figure><p>运行该配置:</p><p><img src="img/QQ截图20191119191043.png" alt="QQ截图20191119191043.png"></p><p>使用浏览器访问<a href="http://192.168.33.11:30000/hello" target="_blank" rel="noopener">http://192.168.33.11:30000/hello</a>:</p><p><img src="img/QQ截图20191119192134.png" alt="QQ截图20191119192134.png"></p><p>至此Spring Boot项目已经成功运行在Kubernetes集群中了，接下来开始演示如何进行CICD。</p><h2 id="CICD实践"><a href="#CICD实践" class="headerlink" title="CICD实践"></a>CICD实践</h2><p>就如上面CICD流程图所示，第一步将本地开发代码push到GitLab已经实现了，接下来开始配置GitLab WebHook。</p><h3 id="GitLab-WebHook"><a href="#GitLab-WebHook" class="headerlink" title="GitLab WebHook"></a>GitLab WebHook</h3><p>在Jenkins中创建流水线前，先修改两处Jenkins配置。点击Jenkins管理页面的<strong>系统管理</strong>菜单 -&gt; <strong>全局安全配置</strong>：</p><p><img src="img/QQ截图20191120091638.png" alt="QQ截图20191120091638.png"></p><p>关闭CSRF保护和开启匿名用户具有可读权限。</p><p>然后点击<strong>新建任务</strong>菜单，新增一个名称为demo的流水线，勾选<strong>触发远程构建</strong>：</p><p><img src="img/QQ截图20191120091910.png" alt="QQ截图20191120091910.png"></p><p>令牌设置为666666，触发地址为<code>JENKINS_URL/job/demo/build?token=TOKEN_NAME</code>，我们需要将这个地址配置为GitLab的WebHook中。</p><p>打开GitLab的Demo项目页面，点击左侧的设置菜单：</p><p><img src="img/QQ截图20191120092313.png" alt="QQ截图20191120092313.png"></p><p>选择integrations：</p><p><img src="img/QQ截图20191120092425.png" alt="QQ截图20191120092425.png"></p><p>其中<code>http://192.168.33.11:8081</code>为我的Jenkins地址，对应JENKINS_URL；666666是我们设置的令牌，对应TOKEN_NAME。触发事件选择push event就行。</p><p>保存WebHook的时候如果提示<span style="color:red;font-weight:600">Url is blocked: Requests to the local network are not allowed</span>的话，可以使用<a href="mailto:admin@example.com" target="_blank" rel="noopener">admin@example.com</a>账号登录GitLab（密码就是你第一次登录修改的密码），然后点击<strong>Admin Area</strong>-&gt;<strong>Settings</strong>-&gt;<strong>Network</strong>：</p><p><img src="img/QQ截图20191120093459.png" alt="QQ截图20191120093459.png"></p><p>勾选Allow requests to the local network from web hooks and services即可。保存后，重新使用mrbird账号登录重新配置WebHook即可。</p><p>配置好后，测试一下：</p><p><img src="img/QQ截图20191120094028.png" alt="QQ截图20191120094028.png"></p><p>页面弹出如下提示说明配置🆗：</p><p><img src="img/QQ截图20191120094121.png" alt="QQ截图20191120094121.png"></p><h3 id="代码拉取"><a href="#代码拉取" class="headerlink" title="代码拉取"></a>代码拉取</h3><p>Maven打包前需要先用git命令将代码拉取下来。编辑刚刚创建的流水线，在Pipeline script中添加如下代码：</p><p><img src="img/QQ截图20191120141218.png" alt="QQ截图20191120141218.png"></p><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#!groovy</span></span><br><span class="line">pipeline &#123;</span><br><span class="line">  agent any</span><br><span class="line">  environment &#123;</span><br><span class="line">    REPOSITORY=<span class="string">"ssh://git@gitlab.mrbird.cc:2223/mrbird/demo.git"</span></span><br><span class="line">  &#125;</span><br><span class="line">  stages &#123;</span><br><span class="line">    stage(<span class="string">'拉取代码'</span>) &#123;</span><br><span class="line">      steps &#123;</span><br><span class="line">        <span class="built_in">echo</span> <span class="string">"从GitLab地址<span class="variable">$&#123;REPOSITORY&#125;</span>拉取代码"</span></span><br><span class="line">        deleteDir()</span><br><span class="line">        git <span class="string">"<span class="variable">$&#123;REPOSITORY&#125;</span>"</span></span><br><span class="line">      &#125;</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure><p></p><p>Pipeline script的基本模板为：</p><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#!groovy</span></span><br><span class="line">pipeline &#123;</span><br><span class="line">  agent any</span><br><span class="line">  environment &#123;</span><br><span class="line">    // 定义全局变量</span><br><span class="line">  &#125;</span><br><span class="line">  stages &#123;</span><br><span class="line">  	// 可以定义多个阶段</span><br><span class="line">    stage(<span class="string">'阶段名称'</span>) &#123;</span><br><span class="line">      steps &#123;</span><br><span class="line">        // 具体步骤</span><br><span class="line">      &#125;</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure><p></p><p>回到上面的Pipeline script代码，我们主要做了下面几件事：</p><ol><li><p>在environment中定义GitLab项目仓库地址变量，方便下面直接引用；</p></li><li><p>通过<code>echo</code>命令输出，方便后续从日志中观察跟踪；</p></li><li><p>通过<code>deleteDir()</code>清空工作区；</p></li><li><p>通过<code>git &quot;${REPOSITORY}&quot;</code>从指定Git仓库拉取代码。</p></li></ol><p>其中，使用environment中的变量时候，一定要用<code>&quot;${xx}&quot;</code>的方式引用；第3第4步的命令可以通过流水线语法来生成，比如生成清空当前目录的命令：</p><p><img src="img/QQ截图20191120141809.png" alt="QQ截图20191120141809.png"></p><p>生成通过Git拉取代码的命令：</p><p><img src="img/QQ截图20191120141908.png" alt="QQ截图20191120141908.png"></p><p>修改好流水线后，点击<strong>立即构建</strong>，看看我们的配置是否🆗：</p><p><img src="img/20191120142110.png" alt="20191120142110.png"></p><p>从日志来看，代码拉取是成功的。</p><h3 id="Maven打包和单元测试"><a href="#Maven打包和单元测试" class="headerlink" title="Maven打包和单元测试"></a>Maven打包和单元测试</h3><p>Jenkins 通过shell脚本调用mvn 命令的时候，是从/usr/bin 文件夹中找命令的，这个时候需要做个软链接：</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ln -s /home/vagrant/apache-maven-3.6.2/bin/mvn /usr/bin/mvn</span><br></pre></td></tr></table></figure><p></p><p>更新流水线的Pipeline script，添加maven打包阶段命令：</p><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#!groovy</span></span><br><span class="line">pipeline &#123;</span><br><span class="line">  agent any</span><br><span class="line">  environment &#123;</span><br><span class="line">    REPOSITORY=<span class="string">"ssh://git@gitlab.mrbird.cc:2223/mrbird/demo.git"</span></span><br><span class="line">  &#125;</span><br><span class="line">  stages &#123;</span><br><span class="line">    stage(<span class="string">'拉取代码'</span>) &#123;</span><br><span class="line">      steps &#123;</span><br><span class="line">        <span class="built_in">echo</span> <span class="string">"从GitLab地址<span class="variable">$&#123;REPOSITORY&#125;</span>拉取代码"</span></span><br><span class="line">        deleteDir()</span><br><span class="line">        git <span class="string">"<span class="variable">$&#123;REPOSITORY&#125;</span>"</span></span><br><span class="line">      &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    stage(<span class="string">'代码编译及单元测试'</span>) &#123;</span><br><span class="line">      steps &#123;</span><br><span class="line">        <span class="built_in">echo</span> <span class="string">"开始编译代码和单元测试"</span></span><br><span class="line">        sh <span class="string">"mvn -U -am clean package"</span></span><br><span class="line">      &#125;</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure><p></p><p>maven打包前会自动运行我们在项目里写好的单元测试，修改后，点击<strong>立即构建</strong>，查看日志（截取关键部分）：</p><p><img src="img/QQ截图20191121170401.png" alt="QQ截图20191120154051.png"></p><p><img src="img/QQ截图20191121170425.png" alt="QQ截图20191120154144.png"></p><p><img src="img/QQ截图20191121170512.png" alt="QQ截图20191120154249.png"></p><p>可以看到单元测试及打包成功。</p><h3 id="构建镜像及推送"><a href="#构建镜像及推送" class="headerlink" title="构建镜像及推送"></a>构建镜像及推送</h3><p>镜像构建和推送涉及命令较多，所以可以定义一个脚本：</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">vim build_push.sh</span><br></pre></td></tr></table></figure><p></p><p>脚本内容如下所示：</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">#!/bin/bash</span><br><span class="line"></span><br><span class="line">MODULE=$1</span><br><span class="line">TIME=`date &quot;+%Y%m%d%H%M&quot;`</span><br><span class="line">GIT_REVISION=`git log -1 --pretty=format:&quot;%h&quot;`</span><br><span class="line">IMAGE_NAME=docker.mrbird.cc/febs/$&#123;MODULE&#125;:$&#123;TIME&#125;_$&#123;GIT_REVISION&#125;</span><br><span class="line"></span><br><span class="line">docker build -t $&#123;IMAGE_NAME&#125; .</span><br><span class="line"></span><br><span class="line">docker push $&#123;IMAGE_NAME&#125;</span><br><span class="line"></span><br><span class="line">echo &quot;$&#123;IMAGE_NAME&#125;&quot; &gt; image_name</span><br></pre></td></tr></table></figure><p></p><p>上面脚本定义了三个变量：</p><ol><li><p>MODULE，模块名称，由脚本执行的时候传入；</p></li><li><p>TIME，时间字符串；</p></li><li><p>GIT_REVISION，git 提交历史哈希码的前7位；</p></li><li><p>IMAGE_NAME，镜像名称。</p></li></ol><p>脚本做的事情很简单，根据当前目录的Dockerfile构建Docker镜像，然后将镜像推送到Harbor仓库，推送后，将镜像名称写到当前目录下的image_name文件中（供后续使用）。</p><p>给脚本添加可执行权限：</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">chmod +x build_push.sh</span><br></pre></td></tr></table></figure><p></p><p>修改Pipeline script，新增构建镜像及推送阶段命令：</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><span class="line">#!groovy</span><br><span class="line">pipeline &#123;</span><br><span class="line">  agent any</span><br><span class="line">  environment &#123;</span><br><span class="line">    REPOSITORY=&quot;ssh://git@gitlab.mrbird.cc:2223/mrbird/demo.git&quot;</span><br><span class="line">    SCRIPT_PATH=&quot;/home/vagrant/bash&quot;</span><br><span class="line">  &#125;</span><br><span class="line">  stages &#123;</span><br><span class="line">    stage(&apos;拉取代码&apos;) &#123;</span><br><span class="line">      steps &#123;</span><br><span class="line">        echo &quot;从GitLab地址$&#123;REPOSITORY&#125;拉取代码&quot;</span><br><span class="line">        deleteDir()</span><br><span class="line">        git &quot;$&#123;REPOSITORY&#125;&quot;</span><br><span class="line">      &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    stage(&apos;代码编译及单元测试&apos;) &#123;</span><br><span class="line">      steps &#123;</span><br><span class="line">        echo &quot;开始编译代码和单元测试&quot;</span><br><span class="line">        sh &quot;mvn -U -am clean package&quot;</span><br><span class="line">      &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    stage(&apos;Docker镜像构建及推送&apos;) &#123;</span><br><span class="line">      steps &#123;</span><br><span class="line">        echo &quot;开始构建Docker镜像并推送到Harbor&quot;</span><br><span class="line">        sh &quot;$&#123;SCRIPT_PATH&#125;/build_push.sh demo&quot;</span><br><span class="line">      &#125;</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure><p></p><p>其中<code>SCRIPT_PATH</code>是上面定义的脚本的路径。</p><p>修改好Pipeline script，重新点击<strong>立即构建</strong>，截取和这部分相关的日志：</p><p><img src="img/20191121184651.png" alt="20191121184651.png"></p><p>查看镜像列表：</p><p><img src="img/QQ截图20191121184855.png" alt="QQ截图20191121184855.png"></p><p><img src="img/QQ截图20191121184943.png" alt="QQ截图20191121184943.png"></p><h3 id="Kubernetes-Deployment升级"><a href="#Kubernetes-Deployment升级" class="headerlink" title="Kubernetes Deployment升级"></a>Kubernetes Deployment升级</h3><p>在<code>/home/vagrant/bash</code>目录下新建deploy.sh脚本：</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">#!/bin/bash</span><br><span class="line"></span><br><span class="line">IMAGE=`cat image_name`</span><br><span class="line"></span><br><span class="line">kubectl set image deployment/demo-deployment demo=$&#123;IMAGE&#125;</span><br></pre></td></tr></table></figure><p></p><p>脚本内容很简单，就是通过kubectl命令升级相关Pod的镜像，镜像名称从image_name文件中读取。</p><p>修改Pipeline script，添加Kubernetes Deployment升级阶段命令：</p><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#!groovy</span></span><br><span class="line">pipeline &#123;</span><br><span class="line">  agent any</span><br><span class="line">  environment &#123;</span><br><span class="line">    REPOSITORY=<span class="string">"ssh://git@gitlab.mrbird.cc:2223/mrbird/demo.git"</span></span><br><span class="line">    SCRIPT_PATH=<span class="string">"/home/vagrant/bash"</span></span><br><span class="line">  &#125;</span><br><span class="line">  stages &#123;</span><br><span class="line">    stage(<span class="string">'拉取代码'</span>) &#123;</span><br><span class="line">      steps &#123;</span><br><span class="line">        <span class="built_in">echo</span> <span class="string">"从GitLab地址<span class="variable">$&#123;REPOSITORY&#125;</span>拉取代码"</span></span><br><span class="line">        deleteDir()</span><br><span class="line">        git <span class="string">"<span class="variable">$&#123;REPOSITORY&#125;</span>"</span></span><br><span class="line">      &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    stage(<span class="string">'代码编译及单元测试'</span>) &#123;</span><br><span class="line">      steps &#123;</span><br><span class="line">        <span class="built_in">echo</span> <span class="string">"开始编译代码和单元测试"</span></span><br><span class="line">        sh <span class="string">"mvn -U -am clean package"</span></span><br><span class="line">      &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    stage(<span class="string">'Docker镜像构建及推送'</span>) &#123;</span><br><span class="line">      steps &#123;</span><br><span class="line">        <span class="built_in">echo</span> <span class="string">"开始构建Docker镜像并推送到Harbor"</span></span><br><span class="line">        sh <span class="string">"<span class="variable">$&#123;SCRIPT_PATH&#125;</span>/build_push.sh demo"</span></span><br><span class="line">      &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    stage(<span class="string">'更新Kubernetes Deployment'</span>) &#123;</span><br><span class="line">      steps &#123;</span><br><span class="line">        <span class="built_in">echo</span> <span class="string">"开始更新Kubernetes Deployment"</span></span><br><span class="line">        sh <span class="string">"<span class="variable">$&#123;SCRIPT_PATH&#125;</span>/deploy.sh"</span></span><br><span class="line">      &#125;</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure><p></p><p>修改后，点击<strong>立即构建</strong>：</p><p><img src="img/QQ截图20191121192052.png" alt="QQ截图20191121192052.png"></p><p>至此我们整条CICD流程就已经都通了，下面测试下CICD。</p><h2 id="效果测试"><a href="#效果测试" class="headerlink" title="效果测试"></a>效果测试</h2><p>如上面所示，我们访问<a href="http://192.168.33.11:30000/hello" target="_blank" rel="noopener">http://192.168.33.11:30000/hello</a>，页面返回hello world，我们在IDEA中修改Controller方法：</p><p><img src="img/QQ截图20191121190234.png" alt="QQ截图20191121190234.png"></p><p>同时修改单元测试方法：</p><p><img src="img/QQ截图20191121190318.png" alt="QQ截图20191121190318.png"></p><p>修改后在IDEA的命令窗口输入：</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">git commit -am update</span><br><span class="line"></span><br><span class="line">git push origin master</span><br></pre></td></tr></table></figure><p></p><p>将最新的代码提交到GitLab后，过一小会刷新<a href="http://192.168.33.11:30000/hello" target="_blank" rel="noopener">http://192.168.33.11:30000/hello</a>，可以看到，我们修改的内容已经生效了：</p><p><img src="img/QQ截图20191121191654.png" alt="QQ截图20191121191654.png"></p><script>$(".post-body a").not(".thispage").addClass("ignore-href").attr("target","_blank")</script></div><div></div><div><div style="padding:10px 0;margin:20px auto;width:90%;text-align:center;color:#878787"><div>请作者喝瓶肥宅水~</div><button id="rewardButton" style="margin-top:10px" disable="enable" onclick='var e=document.getElementById("QR");"none"===e.style.display?e.style.display="block":e.style.display="none"'><span style="height:46px;width:46px;line-height:46px;border-radius:50%;color:#fe5f55;font-weight:600;background:#ffd5be;border:none;box-shadow:0 4px 8px 0 rgba(255,213,190,.4)">￥</span></button><div id="QR" style="display:none"><div id="wechat" style="display:inline-block"><img id="wechat_qr" src="/img/wechat_pay.png" alt="MrBird WeChat Pay"></div><div id="alipay" style="display:inline-block"><img id="alipay_qr" src="/img/ali_pay.png" alt="MrBird Alipay"></div></div></div><style>#QR img{width:auto;margin:.8em 1em 0 1em}</style></div><div><ul class="post-copyright"><li class="post-copyright-author"><strong>本文作者：</strong> MrBird</li><li class="post-copyright-link"><strong>本文链接：</strong> <a href="http://mrbird.cc/CI-CD-Practice-Note.html" title="CI/CD实践笔记">http://mrbird.cc/CI-CD-Practice-Note.html</a></li><li class="post-copyright-license"><strong>版权声明： </strong>本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" rel="external nofollow" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明出处！</li></ul></div><footer class="post-footer"><div class="post-tags" style="margin-bottom:1.3rem"><a href="/tags/GitLab/" rel="tag"># GitLab</a> <a href="/tags/CI-CD/" rel="tag"># CI/CD</a> <a href="/tags/DevOps/" rel="tag"># DevOps</a> <a href="/tags/Harbor/" rel="tag"># Harbor</a> <a href="/tags/Kubernetes/" rel="tag"># Kubernetes</a> <a href="/tags/Jenkins/" rel="tag"># Jenkins</a></div><div class="post-nav"><div class="post-nav-next post-nav-item"><a href="/GitLab-Jenkins-Install-Note.html" rel="next" title="GitLab & Jenkins安装小记"><i class="fa fa-chevron-left"></i> GitLab & Jenkins安装小记</a></div><span class="post-nav-divider"></span><div class="post-nav-prev post-nav-item"><a href="/Kubernetes-PV-PVC.html" rel="prev" title="Kubernetes PV/PVC">Kubernetes PV/PVC <i class="fa fa-chevron-right"></i></a></div></div></footer></article><hr><div id="container"></div><div class="post-spread"><div id="comment-div"></div><style>.valine .vlist{margin-bottom:3rem}.valine .vwrap .vcontrol .col.col-60{text-align:left}.valine .vlist .vcard .vhead,.valine .vlist .vcard section .vfooter{text-align:left}.valine .vlist .vcard section{padding-bottom:.5rem!important}.vname{color:#42b983!important}.valine .vinfo .col{text-align:left;margin-left:-27rem}div#comment-div{margin-bottom:-8rem}.valine .vlist .vcard .vcontent .code,.valine .vlist .vcard .vcontent code,.valine .vlist .vcard .vcontent pre{background:#fbfbfb}.valine .vlist .vcard .vcontent a{color:#42b983}.valine .vlist .vcard .vimg{border-radius:3px}.valine .vbtn{border-radius:2px;padding:.3rem 1.25rem}.valine .vbtn:active,.valine .vbtn:hover{color:#42b983;border-color:#42b983;background-color:#fff}.valine .vwrap .vheader .vinput:focus{border-bottom-color:#42b983}.valine .vlist .vcard .vcontent.expand:before{background:-webkit-gradient(linear,left top,left bottom,from(hsla(0,0%,100%,0)),to(hsla(0,0%,100%,.2)));background:linear-gradient(180deg,hsla(0,0%,100%,0),hsla(0,0%,100%,.2))}.valine .vlist .vcard .vcontent.expand:after{content:"点击展开";font-size:.4rem;text-align:right;left:-1rem;background:hsla(0,0%,100%,.2)}.valine .vlist .vcard section .vfooter .vat{color:#b3b3b3}.valine .vlist .vcard section .vfooter .vat:hover{color:#42b983}.vcontent img{margin:0}.valine .info{display:none}</style><script type="text/javascript" src="/js/av.min.js"></script><script type="text/javascript" src="/js/Valine.min.js"></script><script type="text/javascript" src="/js/activate-power-mode.js"></script><script>POWERMODE.colorful=!0,POWERMODE.shake=!1,document.body.addEventListener("input",POWERMODE),new Valine({el:"#comment-div",notify:!1,verify:!0,appId:"SMcDFP1bN1jgb9Lo8JmtICHm-gzGzoHsz",appKey:"dH4nrUrt3V5XiJiI6Qyejnbi",placeholder:"",path:window.location.pathname,avatar:"monsterid",guest_info:["nick","mail","link"]});var chicken='<a href="#"><img src="https://image.uisdc.com/wp-content/uploads/2018/06/uisdc-chat-chicken.gif" class="checken"></a>';$("#comment-div").prepend(chicken)</script></div></div><script>var $bqinline=$("img[alt='bq-inline']");$bqinline.css({width:"2.3rem",height:"2.3rem",display:"inline","vertical-align":"text-bottom"})</script></div><div class="comments" id="comments"></div></div><aside id="sidebar" class="sidebar" onselectstart="return!1"><div class="sidebar-inner"><ul class="sidebar-nav motion-element"><li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">Contents</li><li class="sidebar-nav-overview" data-target="site-overview">Site Preview</li></ul><section class="site-overview sidebar-panel"><div class="sidebar-sticky sticky"><div itemscope itemtype="http://schema.org/Person"><div class="author__avatar"><img src="/images/blogImage.jpg" class="author__avatar" alt="MrBird" itemprop="image"></div><div class="author__content"><h3 class="author__name" itemprop="name">MrBird's Blog</h3><p class="author__bio" itemprop="description">A simple blog, code repository, just keep blogging</p></div><div class="author__urls-wrapper"><button class="btn btn--inverse">Follow</button><ul class="author__urls social-icons"><li><a href="http://map.baidu.com/?newmap=1&s=s%26wd%3D%E7%A6%8F%E5%B7%9E%E5%B8%82%26c%3D300&from=alamap&tpl=mapcity" target="_blank" itemprop="url" class="ignore-href"><i class="fa fa-fw fa-map-marker" aria-hidden="true"></i>&nbsp;&nbsp;FuZhou,CN</a></li><li><a href="https://love.mrbird.cc" target="_blank" itemprop="url" class="ignore-href"><i class="fa fa-fw fa-diamond" aria-hidden="true"></i>&nbsp;&nbsp;Love</a></li><li><a href="https://cloud.mrbird.cn" target="_blank" itemprop="url" class="ignore-href"><i class="fa fa-fw fa-chain" aria-hidden="true"></i>&nbsp;&nbsp;FEBS</a></li><li><a href="/atom.xml" target="_blank" itemprop="url" class="ignore-href"><i class="fa fa-fw fa-rss" aria-hidden="true"></i>&nbsp;&nbsp;RSS</a></li><li><a href="https://gitee.com/mrbirdd" target="_blank" itemprop="sameAs" class="ignore-href"><i class="fa fa-fw fa-codepen" aria-hidden="true"></i>&nbsp;&nbsp;Gitee</a></li><li><a href="https://github.com/wuyouzhuguli" target="_blank" itemprop="sameAs" class="ignore-href"><i class="fa fa-fw fa-github-alt" aria-hidden="true"></i>&nbsp;&nbsp;GitHub</a></li><li><a href="javascript:;" class="popup-trigger"><i class="fa fa-fw fa-search" aria-hidden="true"></i>&nbsp;&nbsp;Search</a></li></ul></div></div></div><script>var $urls=$(".author__urls").find("a");$urls.each(function(){var o=$(this);o.mouseenter(function(){o.css({color:"#414547"})}),o.mouseleave(function(){o.css({color:""})})})</script></section><section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active"><div class="post-toc"><div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#实践准备"><span class="nav-number">1.</span> <span class="nav-text">实践准备</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#CICD流程图"><span class="nav-number">1.1.</span> <span class="nav-text">CICD流程图</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#项目准备"><span class="nav-number">1.2.</span> <span class="nav-text">项目准备</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#GitLab准备"><span class="nav-number">1.3.</span> <span class="nav-text">GitLab准备</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Kubernetes部署SpringBoot项目"><span class="nav-number">1.4.</span> <span class="nav-text">Kubernetes部署SpringBoot项目</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#CICD实践"><span class="nav-number">2.</span> <span class="nav-text">CICD实践</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#GitLab-WebHook"><span class="nav-number">2.1.</span> <span class="nav-text">GitLab WebHook</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#代码拉取"><span class="nav-number">2.2.</span> <span class="nav-text">代码拉取</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Maven打包和单元测试"><span class="nav-number">2.3.</span> <span class="nav-text">Maven打包和单元测试</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#构建镜像及推送"><span class="nav-number">2.4.</span> <span class="nav-text">构建镜像及推送</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Kubernetes-Deployment升级"><span class="nav-number">2.5.</span> <span class="nav-text">Kubernetes Deployment升级</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#效果测试"><span class="nav-number">3.</span> <span class="nav-text">效果测试</span></a></li></ol></div></div></section></div></aside></div></main><footer id="footer" class="footer" onselectstart="return!1"><div class="footer-inner"><div class="copyright">&copy; 2016 - <span itemprop="copyrightYear">2019</span>&nbsp;&nbsp; <span class="author" itemprop="copyrightHolder">MrBird</span>&nbsp;&nbsp;|<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>&nbsp;&nbsp;UV&nbsp;<span class="busuanzi-value" id="busuanzi_value_site_uv" style="cursor:pointer" title="统计开始时间：2019年7月5日"></span> &nbsp;&nbsp;PV&nbsp;<span class="busuanzi-value" id="busuanzi_value_site_pv" style="cursor:pointer" title="统计开始时间：2019年7月5日"></span></div></div></footer><div class="back-to-top"><span style="font-family:'Source Sans Pro','Helvetica Neue',Arial,sans-serif;font-size:1.2em;font-weight:600">TOP</span></div></div><script type="text/javascript">"[object Function]"!==Object.prototype.toString.call(window.Promise)&&(window.Promise=null)</script><script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script><script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script><script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script><script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script><script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script><script type="text/javascript" src="/js/src/utils.js?v=5.1.1"></script><script type="text/javascript" src="/js/src/motion.js?v=5.1.1"></script><script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.1"></script><script type="text/javascript" src="/js/src/post-details.js?v=5.1.1"></script><script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.1"></script><script type="text/javascript">function proceedsearch(){$("body").append('<div class="search-popup-overlay local-search-pop-overlay"></div>').css("overflow","hidden"),$(".search-popup-overlay").click(onPopupClose),$(".popup").toggle();var t=$("#local-search-input");t.attr("autocapitalize","none"),t.attr("autocorrect","off"),t.focus()}var isfetched=!1,isXml=!0,search_path="search.xml";0===search_path.length?search_path="search.xml":search_path.endsWith("json")&&(isXml=!1);var path="/"+search_path,onPopupClose=function(t){$(".popup").hide(),$("#local-search-input").val(""),$(".search-result-list").remove(),$("#no-result").remove(),$(".local-search-pop-overlay").remove(),$("body").css("overflow","")},searchFunc=function(t,e,o){"use strict";$("body").append('<div class="search-popup-overlay local-search-pop-overlay"><div id="search-loading-icon"><i class="fa fa-spinner fa-pulse fa-2x fa-fw"></i></div></div>').css("overflow","hidden"),$("#search-loading-icon").css("margin","20% auto 0 auto").css("text-align","center"),$.ajax({url:t,dataType:isXml?"xml":"json",async:!0,success:function(t){isfetched=!0,$(".popup").detach().appendTo(".header-inner");var n=isXml?$("entry",t).map(function(){return{title:$("title",this).text(),content:$("content",this).text(),url:$("url",this).text()}}).get():t,r=document.getElementById(e),s=document.getElementById(o),a=function(){var t=r.value.trim().toLowerCase(),e=t.split(/[\s\-]+/);e.length>1&&e.push(t);var o=[];if(t.length>0&&n.forEach(function(n){function r(e,o,n,r){for(var s=r[r.length-1],a=s.position,i=s.word,l=[],h=0;a+i.length<=n&&0!=r.length;){i===t&&h++,l.push({position:a,length:i.length});var p=a+i.length;for(r.pop();0!=r.length&&(s=r[r.length-1],a=s.position,i=s.word,p>a);)r.pop()}return c+=h,{hits:l,start:o,end:n,searchTextCount:h}}function s(t,e){var o="",n=e.start;return e.hits.forEach(function(e){o+=t.substring(n,e.position);var r=e.position+e.length;o+='<b class="search-keyword">'+t.substring(e.position,r)+"</b>",n=r}),o+=t.substring(n,e.end)}var a=!1,i=0,c=0,l=n.title.trim(),h=l.toLowerCase(),p=n.content.trim().replace(/<[^>]+>/g,""),u=p.toLowerCase(),f=decodeURIComponent(n.url),d=[],g=[];if(""!=l&&(e.forEach(function(t){function e(t,e,o){var n=t.length;if(0===n)return[];var r=0,s=[],a=[];for(o||(e=e.toLowerCase(),t=t.toLowerCase());(s=e.indexOf(t,r))>-1;)a.push({position:s,word:t}),r=s+n;return a}d=d.concat(e(t,h,!1)),g=g.concat(e(t,u,!1))}),(d.length>0||g.length>0)&&(a=!0,i=d.length+g.length)),a){[d,g].forEach(function(t){t.sort(function(t,e){return e.position!==t.position?e.position-t.position:t.word.length-e.word.length})});var v=[];0!=d.length&&v.push(r(l,0,l.length,d));for(var C=[];0!=g.length;){var $=g[g.length-1],m=$.position,x=$.word,w=m-20,y=m+80;w<0&&(w=0),y<m+x.length&&(y=m+x.length),y>p.length&&(y=p.length),C.push(r(p,w,y,g))}C.sort(function(t,e){return t.searchTextCount!==e.searchTextCount?e.searchTextCount-t.searchTextCount:t.hits.length!==e.hits.length?e.hits.length-t.hits.length:t.start-e.start});var T=parseInt("1");T>=0&&(C=C.slice(0,T));var b="";b+=0!=v.length?"<li><a href='"+f+"' class='search-result-title'>"+s(l,v[0])+"</a>":"<li><a href='"+f+"' class='search-result-title'>"+l+"</a>",C.forEach(function(t){b+="<a href='"+f+'\'><p class="search-result">'+s(p,t)+"...</p></a>"}),b+="</li>",o.push({item:b,searchTextCount:c,hitCount:i,id:o.length})}}),1===e.length&&""===e[0])s.innerHTML='<div id="no-result"><i class="fa fa-search fa-5x" /></div>';else if(0===o.length)s.innerHTML='<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>';else{o.sort(function(t,e){return t.searchTextCount!==e.searchTextCount?e.searchTextCount-t.searchTextCount:t.hitCount!==e.hitCount?e.hitCount-t.hitCount:e.id-t.id});var a='<ul class="search-result-list">';o.forEach(function(t){a+=t.item}),a+="</ul>",s.innerHTML=a}};r.addEventListener("input",a),$(".local-search-pop-overlay").remove(),$("body").css("overflow",""),proceedsearch()}})};$(".popup-trigger").click(function(t){t.stopPropagation(),isfetched===!1?searchFunc(path,"local-search-input","local-search-result"):proceedsearch()}),$(".popup-btn-close").click(onPopupClose),$(".popup").click(function(t){t.stopPropagation()}),$(document).on("keyup",function(t){var e=27===t.which&&$(".search-popup").is(":visible");e&&onPopupClose()})</script></body><script>$(function(){$("a").not(".nav-link,.cloud-tie-join-count,.ignore-href,.jstree-anchor").addClass("animsition-link")});var burst1=new mojs.Burst({left:0,top:0,radius:{5:40},children:{shape:"circle",fill:["red","cyan","orange"],fillOpacity:.8,radiusX:3.5,radiusY:3.5}});document.addEventListener("click",function(a){null==a.target.href&&"footer"!=a.target.className&&"copyright"!=a.target.className&&"author__urls social-icons"!=a.target.className&&"author__avatar"!=a.target.className&&"sidebar sidebar-active"!=a.target.className&&burst1.tune({x:a.pageX,y:a.pageY}).generate().replay()})</script><script type="text/javascript" src="/js/message.js"></script></html><!-- rebuild by neat -->